﻿using T4UtilityBelt.Writers;

namespace T4UtilityBelt.UxDesigns.Controls.Renderers.Windows
{
    public class GridRowRenderer : ContentElementRenderer<GridRow, IGridRowRenderer>, IGridRowRenderer
    {
        public void RenderGridRowDefinition(GridRow control, CodeWriter writer)
        {
            writer.WriteBeginTag("RowDefinition");

            writer.WriteAttribute("Height", control.Height);
            writer.WriteAttribute("MaxHeight", control.MaxHeight);
            writer.WriteAttribute("MinHeight", control.MinHeight);

            writer.WriteFullEnd();
        }

        protected override void OnRenderUiXmlContent(GridRow control, CodeWriter writer)
        {
            int ci = 0;
            foreach (Control c in control.Controls)
            {
                c.GridColumn = ci;
                c.GridRow = control.GridRowNr;
                c.RenderUiXml(writer);
                ci++;
            }
        }
    }
}